package com.htjc.integral.interactionouter.service.impl;



import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.htjc.integral.common.annotation.InvokeLog;
import com.htjc.integral.interactionouter.service.IInvokeService;
import com.htjc.integral.interactionouter.util.DebHandleCallInner;

import lombok.extern.slf4j.Slf4j;

@Slf4j(topic="outerLogger")
@Service(version = "${dubbo.version}",
application = "${dubbo.application.id}",
protocol = "${dubbo.protocol.id}",
registry = "${dubbo.registry.id}"
		)
/**
 *  强隔离内外网穿透
 * @param req
 * @return
 * @author zw
 */
public class InvokeServiceImpl implements IInvokeService  {
	@Autowired
	private DebHandleCallInner debChannel;

	public InvokeServiceImpl() {
		System.out.println("提供者。。。。。。。。。");
	}

	/**
	 * 存储过程内外网穿透
	 * @param req
	 * @return
	 */
//	@InvokeLog(value="强隔离内外网穿透",params={"data","wsdurl"})
	public String invokeQuery(String params) {
//		params = "{'wsdurl':'11','data':'<ROOT><PROVINCE_CODE>330000</PROVINCE_CODE><WSDL_URL>http://10.147.249.205:8280/qdxt/pf_webservice/spptws/lsspureWs/service</WSDL_URL><TARGET_NAME_SPACE>http://service.ws.sp.sppt.lsspure</TARGET_NAME_SPACE><METHOD>invoke</METHOD><SER_PATH>cimsb/cimsb/manage/service/consImBalService</SER_PATH><SER_METHOD_NAME>getImBal</SER_METHOD_NAME><USER_NAME>DZJF</USER_NAME><PASS_WORD>zpepc001</PASS_WORD><DATA><![CDATA[<?xml version='1.0' encoding='UTF-8'?><DBSET><R><C N='srvCode'>LSSP_000180</C><C N='channelCode'>ESGCC</C><C N='acctId'>00099096</C><C N='consNo'>1313706203</C><C N='orgNo'>33101</C></R></DBSET>]]></DATA></ROOT>'}";
		log.info(InvokeServiceImpl.class.getName()+"方法名：invokeQuery()渠道端外网应用积分e+外网服务接口=====start=====");
		//1、校验参数
		JSONObject json = JSON.parseObject(params);
		String req=json.getString("data");
		log.info("接收的请求参数："+req);
		//访问内网的连接地址基本不会变所以用做静态常量
		String wsdlurl =json.getString("wsdurl"); //访问内部方法url
		//调用存储过程
		String result = debChannel.execute(wsdlurl,req);
		log.info("返回值："+result);

		log.info(InvokeServiceImpl.class.getName()+"方法名：invokeQuery()渠道端外网应用积分e+外网服务接口=====end=====");
		return result;
	}

}
